from rest_framework.views import APIView
from meiduo_admin.serializers.login_serializer import *
from rest_framework.response import Response

class LoginAPIView(APIView):

    def post(self, request):
        user_info = request.data
        s = LoginSerializer(data=user_info)
        s.is_valid(raise_exception=True)
        return Response(data = {
            'username': s.validated_data['user'].username,
            'user_id': s.validated_data['user'].id,
            'token': s.validated_data['token']
        })